﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsIndustriesDAL
/// </summary>
public class clsIndustriesDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
 
	public clsIndustriesDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public List<IN_TB_INDUSTRY> GetAllIndustries()
    {
        try
        {
            List<IN_TB_INDUSTRY> objIN_TB_INDUSTRY = new List<IN_TB_INDUSTRY>();
            objIN_TB_INDUSTRY = (from obj in objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies
                                        select obj).ToList();
            return objIN_TB_INDUSTRY;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_INDUSTRY GetAllIndustriesById(int Id)
    {
        try
        {
            IN_TB_INDUSTRY objIN_TB_INDUSTRY = new IN_TB_INDUSTRY();
            objIN_TB_INDUSTRY = (from obj in objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies
                                        where obj.ID == Id
                                        select obj).SingleOrDefault();
            return objIN_TB_INDUSTRY;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveIndustriesMst(IN_TB_INDUSTRY objIN_TB_INDUSTRY)
    {
        try
        {
            IN_TB_INDUSTRY objIN_TB_INDUSTRYD = new IN_TB_INDUSTRY();
            objIN_TB_INDUSTRYD = (from obj in objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies
                                         where obj.ID == objIN_TB_INDUSTRY.ID
                                         select obj).SingleOrDefault();
            if (objIN_TB_INDUSTRYD != null)
            {
                objIN_TB_INDUSTRYD.ID = objIN_TB_INDUSTRY.ID;
                objIN_TB_INDUSTRYD.INDUSTRY = objIN_TB_INDUSTRY.INDUSTRY;
                objIN_TB_INDUSTRYD.CREATED_BY = objIN_TB_INDUSTRY.CREATED_BY;
                objIN_TB_INDUSTRYD.CREATED_ON = objIN_TB_INDUSTRY.CREATED_ON;
                objIN_TB_INDUSTRYD.MODIFIED_BY = objIN_TB_INDUSTRY.MODIFIED_BY;
                objIN_TB_INDUSTRYD.MODIFIED_ON = objIN_TB_INDUSTRY.MODIFIED_ON;

                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_INDUSTRY.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies.InsertOnSubmit(objIN_TB_INDUSTRY);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_INDUSTRY.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
    public void DeleteIndustries(int Industry_Id)
    {
        try
        {
            IN_TB_INDUSTRY objIN_TB_INDUSTRY = new IN_TB_INDUSTRY();
            objIN_TB_INDUSTRY = (from obj in objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies
                                 where obj.ID == Industry_Id
                                        select obj).SingleOrDefault();
            if (objIN_TB_INDUSTRY != null)
            {
                objInstantNaukriDataContextDataContext.IN_TB_INDUSTRies.DeleteOnSubmit(objIN_TB_INDUSTRY);
                objInstantNaukriDataContextDataContext.SubmitChanges();
            }

        }
        catch (Exception)
        {

            throw;
        }
    }
}
